define(function(){
    var _prefix = '_0_'; //前缀，1、防止冲突,2、更新版本可删除用户缓存
    var _localStorage = {
        isSupport: function (){
            return window.localStorage ? true : false;
        },
        set : function(item, val) {
            try{
               return localStorage.setItem(_prefix+item, val);
            }
            catch(e){
               return _cookie.set(item,val); //iOS的Safari在无痕模式,localStorage异常
            }
             
        },
        get : function(item){
            try{
                return localStorage.getItem(_prefix+item);
            }
            catch(e){
               return _cookie.get(item); //iOS的Safari在无痕模式,localStorage异常
            }
        },
        del : function(item) {
           try{
                return localStorage.removeItem(_prefix+item);
           }
            catch(e){
               return _cookie.del(item); //iOS的Safari在无痕模式,localStorage异常
            }
        }
    };
    var _cookie = {
        set : function(item, val, timeout) {
            timeout = Number(timeout);
            timeout = isNaN(timeout) ? "" : ";expires="+new Date( + new Date() + 1000 * timeout).toUTCString();
            document.cookie = _prefix+item+"="+escape(val)+timeout;
        },
        get : function(item){
            if (document.cookie.length > 0) {
                m = document.cookie.match('(?:^| )' + _prefix+item + '(?:(?:=([^;]*))|;|$)');
                return m ? m[1] : null;
            }
            return null;
        },
        del : function(item) {
            _cookie.set(item,"",-1);
        }
    };
    return {
        get: function(item){
            return _localStorage.isSupport() ? _localStorage.get(item) : _cookie.get(item);
        },
        set: function(item,val,timeout){
            return _localStorage.isSupport() ? _localStorage.set(item,val,timeout) : _cookie.set(item,val,timeout);
        },
        del: function(item){
            return _localStorage.isSupport() ? _localStorage.del(item) : _cookie.del(item);
        }
    };
});
